package com.imooc.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <h1></h1>
 *
 * @author : dzj
 * @create: 2021-04-01 17:54
 */
@RestController
public class RedisController {
    @Autowired
    private RedisTemplate<String,String> redisTemplate;
    @GetMapping("/set")
    public Object hello(String key,String value) {
        redisTemplate.opsForValue().set(key,value);
        return "SUCCESS";

    }

    @GetMapping("/get")
    public Object hello(String key) {
        return redisTemplate.opsForValue().get(key);
    }

    @GetMapping("/delete")
    public Object delete(String key) {
        return redisTemplate.delete(key);
    }
}
